package com.ilove.frame;

import org.kalmeo.kuix.core.Kuix;
import org.kalmeo.kuix.core.KuixConstants;
import org.kalmeo.kuix.widget.Screen;
import org.kalmeo.util.frame.Frame;
import com.vnt.Pad;
import com.ilove.core.*;
public class NullFrame implements Frame {

	public static NullFrame instance = new NullFrame();

	// MainFrame's Screen
	private Screen screen;

	// The Pad that hold all shopLists
	private final Pad pad = new Pad();

	public void onAdded() {
		try {
			// Open the Pad
			pad.setTitle("Lỗi");
			pad.setContent(ILOVEContants.NULL_CONTENT);
			// Preload the screen
			screen = Kuix.loadScreen(ILOVEContants.ABOUT_SCREEN, pad);
			screen.setCurrent();
		} catch (Exception e) {
			Kuix.alert(e);
			e.printStackTrace();
		}
	}

	public boolean onMessage(Object identifier, Object[] arguments) {
		if ("askQuit".equals(identifier)) {
			Kuix.alert(Kuix.getMessage("ASK_QUIT"),
					KuixConstants.ALERT_QUESTION | KuixConstants.ALERT_YES
							| KuixConstants.ALERT_NO, "!exit", null);
			return false;
		}
		if ("back".equals(identifier)) {
			Kuix.getFrameHandler().removeFrame(instance);
			return false;
		}
		return true;
	}

	public void onRemoved() {
		try {
//			com.ilove.lottery.frame.LotteryMainFrame.instance.showScreen();
			com.vnt.SubIndexFrame.instance.showScreen();
			screen.cleanUp();
			screen = null;
		} catch (Exception e) {
			Kuix.alert(e);
			e.printStackTrace();
		}
	}
}
